﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

using AimGameEngine.EditorObject;

using AimGameLibrary;

namespace AimGameEngine.NodeEditorObject
{
    public class NodeTackCamera : NodeBaseControl
    {
        public float speed;
        public Rectangle Bounder;
        public Rectangle Area;
        public Boolean ShowDebugCamera;
        public NodeTackCamera(SpriteBatch inputspritebatch, Camera inputcamera, NodeData inputData
            , List<IDraw> MyListDraw, List<IUpdateMainTime> MyListUpdateTime, Dictionary<String, NodeObject> MyListObject, Dictionary<String, NodeObject> MyListType)
            : base(inputspritebatch, inputcamera, inputData, MyListDraw,MyListUpdateTime, MyListObject, MyListType)
	    {
            speed = 0;
            InputMode = NodeInputMode.None;
            Bounder = new Rectangle(100, -100, -100, 100);
            Area = new Rectangle(0, 0, 1000, 1000);
            ShowDebugCamera = true;

            Connecter outputVector2 = new Connecter(inputspritebatch, inputcamera, Syco.Output, NodeTypeValue.Vector2, this);
            ListConnectpoint.Add(outputVector2);

            Connecter outputUpdate = new Connecter(inputspritebatch, inputcamera, Syco.Output, NodeTypeValue.Update, this);
            ListConnectpoint.Add(outputUpdate);

            Connecter inputVector2 = new Connecter(inputspritebatch, inputcamera, Syco.Input, NodeTypeValue.Vector2, this);
            ListConnectpoint.Add(inputVector2);
        }

        public override void ShowProprety(ArrayList Temp, CallBack input)
        {
            base.ShowProprety(Temp, input);
            PropretyTackCamera propretytackcamera = new PropretyTackCamera(this);
            //propretytackcamera.Deactivate += new EventHandler(input.Deactivate);
            propretytackcamera.okButton.Click += new EventHandler(input.Deactivate);
            propretytackcamera.ShowDialog();
            
        }

        public override void SetupInput(Connecter Thisconnect, Connecter connectOutput)
        {
            MyData.Data = connectOutput.MyNode.MyData.MyName;
        }

        public override void ClearInput(Connecter ThisInputConnect, Connecter ThisConnectClear, string NameThisClear)
        {
            MyData.Data = "NULL";
        }

        protected override Dictionary<string, NodeObject> GetDictionaryNode(Dictionary<string, NodeObject> TempNode)
        {
            if (MyData.Data != null)
                if (this.MyDictionaryObject.ContainsKey(MyData.Data))
                    TempNode.Add(MyData.Data, this.MyDictionaryObject[MyData.Data]);

            return base.GetDictionaryNode(TempNode);
        }

        public override void SaveData(System.Collections.ArrayList Thislist, SaveMode inputsavemode)
        {
            base.SaveData(Thislist, inputsavemode);

            Thislist.Add(InputMode);
            Thislist.Add(speed);

            Thislist.Add(Bounder);
            Thislist.Add(Area);

            Thislist.Add(ShowDebugCamera);
        }

        public override void LoadData(Identification getdata, int IndexData)
        {
            base.LoadData(getdata, IndexData);

            if (getdata.Items.GetValue(IndexData + 1).GetType() == typeof(NodeInputMode))
                InputMode = (NodeInputMode)getdata.Items.GetValue(IndexData + 1);

            if (getdata.Items.GetValue(IndexData + 2).GetType() == typeof(float))
                speed = (float)getdata.Items.GetValue(IndexData + 2);

            if (getdata.Items.GetValue(IndexData + 3).GetType() == typeof(Rectangle))
                Bounder = (Rectangle)getdata.Items.GetValue(IndexData + 3);

            if (getdata.Items.GetValue(IndexData + 4).GetType() == typeof(Rectangle))
                Area = (Rectangle)getdata.Items.GetValue(IndexData + 4);

            if (getdata.Items.GetValue(IndexData + 5).GetType() == typeof(Boolean))
                ShowDebugCamera = (Boolean)getdata.Items.GetValue(IndexData + 5);

        }
    }
}
